﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EditDocument.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.EditDocument" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
        $(document).ready(function(){
            $('#Title').focus();
            
            $("#frmNewDocument").validate({
           rules: {
             Name: "required"
           },
           errorLabelContainer:"#frmDocumentErr",
           messages: {
             Name: "Please enter a title."
           }
        });
        
    });
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="StylePlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% LBRDataContext dc = new LBRDataContext();  %>
    <% Document d = dc.GetDocument(int.Parse(ViewData["DocumentId"].ToString()));
       if (d == null) d = new Document();
       object vals = new {documentId = d.DocumentId };  
    %>
    <div class="contentDiv" style="margin-left:15%; margin-top:20px">
        <form method="post" id="frmNewDocument" enctype="multipart/form-data" action="<%=  Url.Action("SaveOrUpdateDocument", "Admin", vals ) %>" >
            <fieldset id="fldRegister" style="width:500px;display:block;">
                <legend><%= d.DocumentId == 0 ? "New" : "Edit"%> Document</legend>
                <table>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Title">Title:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Title", d.Title)%></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="Description">Description:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Description", d.Description)%></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="File">Upload&nbsp;File :&nbsp;</label></td>
                    <td class="addPropertyField"><input type="file" id="File" name="Doc" size="40" /></td>
                </tr>
                <tr>
                    <td colspan="2"><div id="frmDocumentErr" class="ValidateErrorContainer"></div></td>
                </tr>
                </table>
            </fieldset>
            <div style="display:inline">
                <input type="submit" name="btnSubmit" id="btnSubmit" value = "Save" />
                <button onclick = "window.location ='../Admin.ashx/DocumentList'; return false;">Cancel</button>
            </div>
        </form>
    </div>
</asp:Content>
